home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-07-11 | 23.1 KB | 919 lines | [TEXT/MPS ] |
- (*******************************)
- (* methods for TDesignDocument *)
- (*******************************)
- {$S AOpen}
- PROCEDURE TDesignDocument.IDesignDocument;
-
- VAR
- aList: TList;
- aTextHandler:TTextHandler;
-
- BEGIN
- fCurrentCard:= NIL;
- IDocument(kFileType, kSignature, kUsesDataFork, NOT kUsesRsrcFork,
- NOT kDataOpen, NOT kRsrcOpen);
- fSavePrintInfo:= TRUE;
-
- aList:= NewList;
- fCardList:= aList;
-
- fDesignView:= NIL;
-
- SetUnitName('NotSetYet');
-
- SELF.SetMPWCodeView(NIL);
- SELF.SetMPWIncCodeView(NIL);
-
- NEW(aTextHandler);
- FailNil(aTextHandler);
- aTextHandler.ITTextHandler(SELF);
- SELF.SetTextHandler(aTextHandler);
- END; {TDesignDocument.IDesignDocument}
-
- {$S ARes}
- PROCEDURE TDesignDocument.SetCurrentCard(theCard: TCard);
-
- VAR
- theSimpleView: TSimpleVIew;
-
- BEGIN
- IF fCurrentCard <> NIL THEN
- BEGIN
- theSimpleView:= fCurrentCard.GetSimpleView;
- IF theSimpleView <> NIL THEN
- BEGIN
- theSimpleView.DoHighlightSelection(hlOn, hlOff);
- theSimpleView.SetSelected(NOT kIsSelected);
- END;
- END;
- fCurrentCard:= theCard;
- IF theCard <> NIL THEN
- BEGIN
- theSimpleView:= theCard.GetSimpleView;
- IF theSimpleView <> NIL THEN
- BEGIN
- theSimpleView.SetSelected(kIsSelected);
- theSimpleView.DoHighlightSelection(hlOff, hlOn);
- END;
- END;
- END; {TDesignDocument.SetCurrentCard}
-
- {$S ARes}
- FUNCTION TDesignDocument.GetCurrentCard: TCard;
- BEGIN
- GetCurrentCard:= fCurrentCard;
- END; {TDesignDocument.GetCurrentCard}
-
- {$S ARes}
- PROCEDURE TDesignDocument.SetCardList(theCardList: TList);
- BEGIN
- fCardList:= theCardList;
- END; {TDesignDocument.SetCardList}
-
- {$S ARes}
- FUNCTION TDesignDocument.GetCardList: TList;
- BEGIN
- GetCardList:= fCardList;
- END; {TDesignDocument.GetCardList}
-
- {$S ARes}
- FUNCTION TDesignDocument.GetNumCardsStr: str255;
-
- VAR
- numCards: ArrayIndex;
- theString: str255;
-
- BEGIN
- numCards:= SELF.GetNumCards;
- NumToString(numCards + 1, theString);
- GetNumCardsStr:= theString;
- END; {TDesignDocument.GetNumCardsStr}
-
- {$S ARes}
- FUNCTION TDesignDocument.GetDesignView: TDesignView;
- BEGIN
- GetDesignView:= fDesignView;
- END; {TDesignDocument.GetDesignView}
-
- {$S ARes}
- PROCEDURE TDesignDocument.SetDesignView(aDesignView: TDesignView);
- BEGIN
- fDesignView:= aDesignView;
- END; {TDesignDocument.SetDesignView}
-
- {$S ARes}
- FUNCTION TDesignDocument.GetTextHandler: TTextHandler;
- BEGIN
- GetTextHandler:= fTextHandler;
- END; {TDesignDocument.GetTextHandler}
-
- {$S ARes}
- PROCEDURE TDesignDocument.SetTextHandler(theTextHandler: TTextHandler);
- BEGIN
- fTextHandler:= theTextHandler;
- END; {TDesignDocument.SetTextHandler}
-
- {$S ARes}
- FUNCTION TDesignDocument.GetMPWCodeView: TMyTEView;
-
- BEGIN
- GetMPWCodeView:= fMPWCodeView;
- END; {TDesignDocument.GetMPWCodeView}
-
- {$S ARes}
- PROCEDURE TDesignDocument.SetMPWCodeView(theMPWCodeView: TMyTEView);
-
- BEGIN
- fMPWCodeView:= theMPWCodeView;
- END; {TDesignDocument.SetMPWCodeView}
-
- {$S ARes}
- FUNCTION TDesignDocument.GetMPWIncCodeView: TMyTEView;
-
- BEGIN
- GetMPWIncCodeView:= fMPWIncCodeView;
- END; {TDesignDocument.GetMPWIncCodeView}
-
- {$S ARes}
- PROCEDURE TDesignDocument.SetMPWIncCodeView(theMPWIncCodeView: TMyTEView);
-
- BEGIN
- fMPWIncCodeView:= theMPWIncCodeView;
- END; {TDesignDocument.SetMPWIncCodeView}
-
- {$S ARes}
- FUNCTION TDesignDocument.GetUnitName:Str255;
- BEGIN
- GetUnitName:=fUnitName;
- END; {TDesignDocument.GetUnitName}
-
- {$S ARes}
- PROCEDURE TDesignDocument.SetUnitName(theUnitName: Str255);
- BEGIN
- fUnitName:=theUnitName;
- END; {TDesignDocument.SetUnitName}
-
- {$S ARes}
- PROCEDURE TDesignDocument.SetTitle(aTitle: Str255); OVERRIDE;
-
- BEGIN
- INHERITED SetTitle(aTitle);
- SELF.SetUnitName(fTitle^^);
- END; {TDesignDocument.SetTitle}
-
- {$S ADoCommand}
- PROCEDURE TDesignDocument.AddCard(aCard: TCard);
-
- BEGIN
- fCardList.InsertLast(aCard);
- IF fDesignView <> NIL THEN
- aCard.CreateSimpleView(fDesignView, SELF);
- SELF.SetCurrentCard(aCard);
- SELF.AddCardToObjectLists(aCard);
- END; {TDesignDocument.AddCard}
-
- {$S ADoCommand}
- PROCEDURE TDesignDocument.AddCardAtIndex(aCard: TCard; theIndex: ArrayIndex);
-
- BEGIN
- IF theIndex <= fCardList.GetSize THEN
- BEGIN
- fCardList.InsertBefore(theIndex, aCard);
- IF fDesignView <> NIL THEN
- aCard.CreateSimpleView(fDesignView, SELF);
- SELF.AddCardToObjectLists(aCard);
- END
- ELSE
- SELF.AddCard(aCard);
- SELF.SetCurrentCard(aCard);
- END; {TDesignDocument.AddCardAtIndex}
-
- {$S ADoCommand}
- PROCEDURE TDesignDocument.AddCardToObjectLists(theCardToAdd: TCard);
-
- PROCEDURE AddTheClass(aCard: TCard);
-
- BEGIN
- aCard.AddCardToObjectLists(theCardToAdd);
- END;
-
- BEGIN
- SELF.GetCardList.Each(AddTheClass);
- END; {TDesignDocument.AddCardToObjectLists}
-
- {$S ADoCommand}
- PROCEDURE TDesignDocument.RemoveCardFromObjectLists(theCardToRemove: TCard);
-
- PROCEDURE RemoveTheClass(aCard: TCard);
-
- BEGIN
- aCard.RemoveCardFromObjectLists(theCardToRemove);
- END;
-
- BEGIN
- SELF.GetCardList.Each(RemoveTheClass);
- END; {TDesignDocument.RemoveCardFromObjectLists}
-
- {$S ADoCommand}
- PROCEDURE TDesignDocument.ChangeNameInObjectLists(theOldName, theNewName: Str255);
-
- PROCEDURE ChangeTheName(aCard: TCard);
-
- BEGIN
- aCard.ChangeNameInObjectLists(theOldName, theNewName);
- END;
-
- BEGIN
- SELF.GetCardList.Each(ChangeTheName);
- END; {TDesignDocument.ChangeNameInObjectLists}
-
- {$S ADoCommand}
- PROCEDURE TDesignDocument.DeleteCard(aCard: TCard);
-
- BEGIN
- fCardList.Delete(aCard);
- SELF.SetCurrentCard(NIL);
- aCard.DeleteSimpleView;
- aCard.DeleteEditView;
- fDesignView.ForceRedraw;
- SELF.RemoveCardFromObjectLists(aCard);
- END; {TDesignDocument.DeleteCard}
-
- {$S ARes}
- FUNCTION TDesignDocument.GetNumCards: ArrayIndex;
-
- BEGIN
- GetNumCards:= fCardList.GetSize;
- END; {TDesignDocument.GetNumCards}
-
- {$S ARes}
- FUNCTION TDesignDocument.GetIndexOfCard(theCard: TCard): ArrayIndex;
-
- BEGIN
- IF theCard <> NIL THEN
- GetIndexOfCard:= fCardList.GetEqualItemNo(theCard)
- ELSE
- GetIndexOfCard:= kCardNotFound;
- END; {TDesignDocument.GetIndexOfCard}
-
- {$S AOpen}
- PROCEDURE TDesignDocument.DoMakeViews(forPrinting: BOOLEAN); OVERRIDE;
-
- VAR
- aWindow: TWindow;
- aDesignView: TDesignView;
- aHandler: TStdPrintHandler;
-
- PROCEDURE MakeSimpleViews(theCard: TCard);
-
- VAR
- theSimpleView: TSimpleView;
-
- BEGIN
- theCard.SetDesignView(aDesignView);
- theCard.CreateSimpleView(fDesignView, SELF);
- theSimpleView:= theCard.GetSimpleView;
- theSimpleView.SetSelected(NOT kIsSelected);
- END; {MakeSimpleViews}
-
- BEGIN
- aWindow := NewTemplateWindow(kDesignWindowID, SELF);
- aDesignView := TDesignView(aWindow.FindSubView('dsgn'));
- SELF.SetDesignView(aDesignView);
- New(aHandler);
- FailNIL(aHandler);
- aHandler.IStdPrintHandler(SELF, aDesignView, NOT kSquareDots, kFixedSize, kFixedSize);
- aHandler.InstallMargins(gZeroRect, kUseMinimalMargins);
-
- IF fCardList.GetSize > kNoCards THEN
- BEGIN
- fCardList.Each(MakeSimpleViews);
- SELF.SetCurrentCard(SELF.GetCurrentCard);
- END;
- END; {TDesignDocument.DoMakeViews}
-
- {$S ARes}
- PROCEDURE TDesignDocument.CloseOldCodeViews;
-
- VAR
- theMPWTextDoc: TMPWTextDocument;
-
- BEGIN
- IF fMPWCodeView <> NIL THEN
- BEGIN
- theMPWTextDoc:= TMPWTextDocument(fMPWCodeView.fDocument);
- theMPWTextDoc.Close;
- END;
- IF fMPWIncCodeView <> NIL THEN
- BEGIN
- theMPWTextDoc:= TMPWTextDocument(fMPWIncCodeView.fDocument);
- theMPWTextDoc.Close;
- END;
- END; {TDesignDocument.CloseOldCodeViews}
-
- {$S ARes}
- PROCEDURE TDesignDocument.OpenNewCodeViews;
-
- VAR
- anMPWIncCodeView: TMyTEView;
- anMPWCodeView: TMyTEView;
- anMPWInterfaceDocument: TMPWInterfaceDocument;
- anMPWImplementationDocument: TMPWImplementationDocument;
-
- BEGIN
- IF fMPWIncCodeView = NIL THEN
- BEGIN
- NEW(anMPWImplementationDocument);
- FailNIL(anMPWImplementationDocument);
- anMPWImplementationDocument.IMPWImplementationDocument(SELF,
- SELF.GetTextHandler,SELF.GetUnitName);
- anMPWImplementationDocument.DoMakeViews(kForPrinting);
- anMPWIncCodeView:= anMPWImplementationDocument.GetTEView;
- anMPWIncCodeView.SetDesignDoc(SELF);
- SELF.SetMPWIncCodeView(anMPWIncCodeView);
- END;
-
- IF fMPWCodeView = NIL THEN
- BEGIN
- NEW(anMPWInterfaceDocument);
- FailNIL(anMPWInterfaceDocument);
- anMPWInterfaceDocument.IMPWInterfaceDocument(SELF,
- SELF.GetTextHandler,SELF.GetUnitName);
-
- anMPWInterfaceDocument.DoMakeViews(kForPrinting);
- anMPWCodeView:= anMPWInterfaceDocument.GetTEView;
- anMPWCodeView.SetDesignDoc(SELF);
- SELF.SetMPWCodeView(anMPWCodeView);
- END;
- END; {TDesignDocument.OpenNewCodeViews}
-
- {$S ARes}
- PROCEDURE TDesignDocument.SelectCurrentCodeViews;
-
- VAR
- theWindow: TWindow;
-
- BEGIN
- theWindow:= fMPWIncCodeView.GetWindow;
- theWindow.Select;
- theWindow:= fMPWCodeView.GetWindow;
- theWindow.Select;
- END; {TDesignDocument.SelectCurrentCodeViews}
-
- {$S ARes}
- PROCEDURE TDesignDocument.WriteInterface(theTEView: TMyTEView);
-
- PROCEDURE WriteTheCardInterfaces(theCard: TCard);
-
- BEGIN
- theCard.WriteInterface(theTEView);
- END;
-
- PROCEDURE WriteTheFwdClassDecl(theCard: TCard);
-
- BEGIN
- theCard.WriteFwdClassDecl(theTEView);
- END;
-
- BEGIN
- theTEView.WriteToMyTEView(fTextHandler.GetHeadingStr);
- IF SELF.GetNumCards > kNoCards THEN
- BEGIN
- fCardList.Each(WriteTheFwdClassDecl);
- fCardList.Each(WriteTheCardInterfaces);
- END;
- theTEView.WriteToMyTEView(fTextHandler.GetImplementationStr);
- theTEView.WriteToMyTEView(fTextHandler.GetIncludeStatement);
- theTEView.WriteToMyTEView(fTextHandler.GetUnitEndStr);
- END; {TDesignDocument.WriteInterface}
-
- {$S ARes}
- PROCEDURE TDesignDocument.WriteImplementation(theTEView: TMyTEView);
-
- PROCEDURE WriteTheCardImplementations(theCard: TCard);
-
- BEGIN
- theCard.WriteImplementation(theTEView);
- END;
-
- BEGIN
- IF SELF.GetNumCards > kNoCards THEN
- BEGIN
- theTEView.WriteToMyTEView(fTextHandler.GetImplIncFileStr);
- fCardList.Each(WriteTheCardImplementations);
- END;
- END; {TDesignDocument.WriteImplementation}
-
- {$S ARes}
- FUNCTION TDesignDocument.GetUnitNameFromUser;
-
- CONST
- kSelectChars = TRUE;
- kUNameView = 'UNAM';
- kUnit = 'Unme';
- kmodalID = 1004;
-
- VAR
- aWindow: TWindow;
- aDialogView: TDialogView;
- theTEName : TEditText;
- dismisser : IDType;
- theName : Str255;
-
- BEGIN
- aWindow := NewTemplateWindow(kmodalID, NIL);
- theTEName := TEditText(aWindow.FindSubView(kUnit));
- theName:=SELF.GetUnitName;
- theTEName.SetText(theName,TRUE);
- aDialogView := TDialogView(aWindow.FindSubView(kUNameView));
- dismisser := aDialogView.PoseModally;
- IF dismisser = 'okok' THEN
- BEGIN
- GetUnitNameFromUser:=TRUE;
- theTEName.GetText(theName);
- SELF.SetUnitName(theName);
- END;
- IF dismisser = 'cncl' THEN
- GetUnitNameFromUser:=FALSE;
- aWindow.Close;
- END; {TDesignDocument.GetUnitNameFromUser}
-
- {$S ARes}
- PROCEDURE TDesignDocument.WriteCode;
-
- BEGIN
- IF (SELF.GetChangeCount > kNoChanges) OR
- (fMPWCodeView = NIL) OR
- (fMPWIncCodeView = NIL) THEN
- BEGIN
- IF SELF.GetUnitNameFromUser THEN
- BEGIN
- SELF.CloseOldCodeViews;
- SELF.OpenNewCodeViews;
- fMPWCodeView.ClearText;
- fMPWIncCodeView.ClearText;
- SELF.WriteInterface(fMPWCodeView);
- SELF.WriteImplementation(fMPWIncCodeView);
- fMPWCodeView.FinishWriteOperation;
- fMPWIncCodeView.FinishWriteOperation;
- END;
- END
- ELSE
- SELF.SelectCurrentCodeViews;
- END; {TDesignDocument.WriteCode}
-
- {$S AClose}
- PROCEDURE TDesignDocument.FreeData; OVERRIDE;
- VAR
- theCardList:TList;
-
- PROCEDURE DeleteTheCard(aCard: TCard);
- BEGIN
- SELF.DeleteCard(aCard);
- aCard.Free;
- END;
-
- BEGIN
- theCardList:=SELF.GetCardList;
- theCardList.Each(DeleteTheCard);
- INHERITED FreeData;
- END; {TDesignDocument.FreeData}
-
- {$S AClose}
- PROCEDURE TDesignDocument.Free; OVERRIDE;
- BEGIN
- IF fMPWCodeView <> NIL THEN
- fMPWCodeView.DesignDocumentIsGone;
- IF fMPWIncCodeView <> NIL THEN
- fMPWIncCodeView.DesignDocumentIsGone;
- IF fCardList <> NIL THEN
- fCardList.FreeList;
- fTextHandler.Free;
- INHERITED Free;
- END; {TDesignDocument.Free}
-
- {$S AWriteFile}
- PROCEDURE TDesignDocument.DoNeedDiskSpace(
- VAR dataForkBytes, rsrcForkBytes: LONGINT); OVERRIDE;
- {
- file format:
- print info (done by MacApp and our INHERIRED call)
- language
- number of cards (ArrayIndex)
- current item (ArrayIndex )
- for each card: (handled by the card objects)
- name of class
- name of super class
- number of fields (ArrayIndex)
- that many strings (str255)
- number of methods (ArrayIndex)
- that many strings (str255)
- number of collaborators (ArrayIndex)
- that many strings (str255)
- *** note *** no accessors are stored, they are created
- during the read operation
- }
-
- VAR
- numCards: INTEGER;
- language: INTEGER;
-
- PROCEDURE CalcOurBytes(theCard: TCard);
-
- BEGIN
- dataForkBytes:= dataForkBytes + theCard.ReturnBytes;
- END; {CalcOurBytes}
-
- BEGIN
- INHERITED DoNeedDiskSpace(dataForkBytes, rsrcForkBytes);
- dataForkBytes:= 0;
- language:= fTextHandler.GetLanguage;
- dataForkBytes:= dataForkBytes + SIZEOF(language);
- numCards:= fCardList.GetSize;
- dataForkBytes:= dataForkBytes + SIZEOF(numCards); { there will at least be a zero }
- dataForkBytes:= dataForkBytes + SIZEOF(ArrayIndex); {for the current item number}
- IF NumCards > 0 THEN
- fCardList.Each(CalcOurBytes);
- END; {TDesignDocument.DoNeedDiskSpace}
-
- {$S AWriteFile}
- PROCEDURE TDesignDocument.DoWrite(aRefNum: INTEGER; makingCopy: BOOLEAN); OVERRIDE;
-
- {
- file format:
- print info (done by MacApp and our INHERIRED call)
- language
- number of cards (ArrayIndex)
- current item (ArrayIndex )
- for each card: (handled by the card objects)
- class name
- super class name
- number of fields (ArrayIndex)
- that many strings (str255)
- number of methods (ArrayIndex)
- that many strings (str255)
- number of collaborators (ArrayIndex)
- that many strings (str255)
- *** note *** no accessors are stored, they are created
- during the read operation
- }
-
- VAR
- numCards,
- currentCardNumber: ArrayIndex;
- language: INTEGER;
- dataBytes: LONGINT;
-
- PROCEDURE WriteACardInTheList(aCard: TCard);
- BEGIN
- aCard.WriteCard(aRefNum);
- END; {WriteACardInTheList}
-
- BEGIN
- {first the print stuff from MacApp}
- INHERITED DoWrite(aRefNum, makingCopy);
-
- {now the language}
- language:= fTextHandler.GetLanguage;
- dataBytes:= SIZEOF(language);
- FailOSErr(FSWrite(aRefNum, dataBytes, @language));
-
- {now the number of cards in our document and the current item number}
- numCards := fCardList.GetSize;
- IF (numCards > kNoCards) AND (SELF.GetCurrentCard <> NIL) THEN
- currentCardNumber:= fCardList.GetEqualItemNo(SELF.GetCurrentCard)
- ELSE
- currentCardNumber:= kNotFound;
- dataBytes := SIZEOF(numCards);
- FailOSErr(FSWrite(aRefNum, dataBytes, @numCards));
- FailOSErr(FSWrite(aRefNum, dataBytes, @currentCardNumber));
-
- {write each card's data if there are any cards}
- IF numCards > kNoCards THEN
- fCardList.Each(WriteACardInTheList);
- END; {TDesignDocument.DoWrite}
-
- {$S AReadFile}
- PROCEDURE TDesignDocument.DoRead(aRefNum: INTEGER;
- rsrcExists, forPrinting: BOOLEAN); OVERRIDE;
-
- {
- file format:
- print info (done by MacApp and our INHERIRED call)
- language
- number of cards (ArrayIndex)
- current item (ArrayIndex )
- for each card: (handled by the card objects)
- name of class
- name of super class
- number of fields (ArrayIndex)
- that many strings (str255)
- number of methods (ArrayIndex)
- that many strings (str255)
- number of collaborators (ArrayIndex)
- that many strings (str255)
- *** note *** no accessors are stored, they are created
- during the read operation
- }
-
- VAR
- language: INTEGER;
- currentItemNum,
- numCards: ArrayIndex;
- aCard: TCard;
- index: ArrayIndex;
- dataBytes: LONGINT;
-
- BEGIN
- INHERITED DoRead(aRefNum, rsrcExists, forPrinting); {read printer info}
-
- SetUnitName(fTitle^^);
- dataBytes:= SIZEOF(language);
- FailOSErr(FSRead(aRefNum, dataBytes, @language));
- fTextHandler.SetLanguage(language);
-
- dataBytes:= SIZEOF(ArrayIndex);
- FailOSErr(FSRead(aRefNum, dataBytes, @numCards));
- FailOSErr(FSRead(aRefNum, dataBytes, @currentItemNum));
-
- IF numCards > 0 THEN
- BEGIN
- FOR index:= 1 to numCards DO
- BEGIN
- NEW(aCard);
- FailNil(aCard);
- aCard.ICard(SELF, gZeroVPt);
- aCard.ReadCard(aRefNum);
- SELF.AddCard(aCard);
- SELF.SetCurrentCard(NIL);
- END;
-
- IF currentItemNum = kNotFound THEN
- SELF.SetCurrentCard(NIL)
- ELSE
- BEGIN
- aCard:= TCard(fCardList.At(currentItemNum));
- SELF.SetCurrentCard(aCard);
- END;
- END;
- END; {TDesignDocument.DoRead}
-
- {$S ASelCommand}
- FUNCTION TDesignDocument.DoMenuCommand(aCmdNumber: CmdNumber):TCommand;OVERRIDE;
-
- BEGIN
- DoMenuCommand:= gNoChanges;
- CASE aCmdNumber OF
- cWriteCodeCmd: SELF.WriteCode;
- cInPascalCmd:
- IF SELF.GetTextHandler.GetLanguage=kInCPP THEN
- BEGIN
- SELF.GetTextHandler.ChangeLanguageTo(kInPascal);
- SELF.SetChangeCount(SELF.GetChangeCount + 1);
- END;
- cInCPPCmd:
- IF SELF.GetTextHandler.GetLanguage=kInPascal THEN
- BEGIN
- SELF.GetTextHandler.ChangeLanguageTo(kInCPP);
- SELF.SetChangeCount(SELF.GetChangeCount + 1);
- END;
- OTHERWISE {always do this, so other objects get a chance}
- DoMenuCommand := INHERITED DoMenuCommand(aCmdNumber);
-
- END; {Case}
- END; {TDesignDocument.DoMenuCommand}
-
-
- {$S ARes}
- PROCEDURE TDesignDocument.DoSetupMenus; OVERRIDE;
-
- VAR
- Index:Integer;
-
- BEGIN
- INHERITED DoSetupMenus;
- IF SELF.GetNumCards > kNoCards THEN
- Enable(cWriteCodeCmd, TRUE);
- FOR Index:=1 TO kNumberOfLanguages DO
- BEGIN
- Enable(Index + cInPascalCmd -1, TRUE);
- EnableCheck(Index + cInPascalCmd -1, TRUE, (Index=SELF.GetTextHandler.GetLanguage));
- END;
- END; {TDesignDocument.DoSetupMenus}
-
-
- {$S AFields}
- PROCEDURE TDesignDocument.Fields(PROCEDURE DoToField(
- fieldName: Str255; fieldAddr: Ptr; fieldType: INTEGER)); OVERRIDE;
- BEGIN
- DoToField('TDesignDocument', NIL, bClass);
- DoToField('fCurrentCard', @fCurrentCard, bObject);
- DoToField('fCardList', @fCardList, bObject);
- DoToField('fDesignView', @fDesignView, bObject);
- DoToField('fTextHandler', @fTextHandler, bObject);
- DoToField('fUnitName', @fUnitName, bString);
- DoToField('fMPWCodeView', @fMPWCodeView, bObject);
- DoToField('fMPWIncCodeView', @fMPWIncCodeView, bObject);
- INHERITED Fields(DoToField);
- END; {TDesignDocument.Fields}
-
-
- (********************************)
- (* methods for TMPWTextDocument *)
- (********************************)
-
- {$S ARes}
- FUNCTION TMPWTextDocument.GetDocText: Handle;
-
- BEGIN
- GetDocText:= fDocText;
- END; {TMPWTextDocument.GetDocText}
-
- {$S ARes}
- PROCEDURE TMPWTextDocument.SetDocText(theHandle: Handle);
-
- BEGIN
- fDocText:= theHandle;
- END; {TMPWTextDocument.SetDocText}
-
- {$S ARes}
- FUNCTION TMPWTextDocument.GetTEView: TMyTEView;
-
- BEGIN
- GetTEView:= fTEView;
- END; {TMPWTextDocument.GetTEView}
-
- {$S ARes}
- PROCEDURE TMPWTextDocument.SetTEView(theTEView: TMyTEView);
-
- BEGIN
- fTEView:= theTEView;
- END; {TMPWTextDocument.SetTEView}
-
- {$S ARes}
- FUNCTION TMPWTextDocument.GetDesignDoc: TDesignDocument;
-
- BEGIN
- GetDesignDoc:= fDesignDocument;
- END; {TMPWTextDocument.GetDesignDoc}
-
- {$S ARes}
- PROCEDURE TMPWTextDocument.SetDesignDoc(theDesignDoc: TDesignDocument);
-
- BEGIN
- fDesignDocument:= theDesignDoc;
- END; {TMPWTextDocument.SetDesignDoc}
-
- {$S ARes}
- PROCEDURE TMPWTextDocument.SetTitleNoDialog(theName: str255);
-
- BEGIN
- INHERITED SetTitle(theName);
- END; {TMPWTextDocument.SetTitleNoDialog}
-
- {$S ARes}
- PROCEDURE TMPWTextDocument.SetTitle(aTitle: str255); OVERRIDE;
-
- BEGIN
- INHERITED SetTitle(aTitle);
- END; {TMPWTextDocument.SetTitle}
-
- {$S AOpen}
- PROCEDURE TMPWTextDocument.IMPWTextDocument(theDesignDoc: TDesignDocument; theName: str255);
-
- BEGIN
- SELF.SetDocText(NIL);
- SELF.IDocument(kMPWFileType, kMPWSignature, kUsesDataFork, kUsesRsrcFork,
- NOT kDataOpen, NOT kRsrcOpen);
- SELF.SetTitleNoDialog(theName);
- SELF.SetTEView(NIL);
- SELF.SetDesignDoc(theDesignDoc);
- END; {TMPWTextDocument.IMPWTextDocument}
-
-
- {$S AOpen}
- PROCEDURE TMPWTextDocument.DoMakeViews(forPrinting: BOOLEAN); OVERRIDE;
-
- VAR
- aView: TView;
- aHandler: TStdPrintHandler;
- aTEView: TMyTEView;
-
- BEGIN
- aView := NewTemplateWindow(kMPWTEViewID, SELF);
- FailNIL(aView);
- aTEView := TMyTEView(aView.FindSubView(kMPWTEViewIdentifier));
- SELF.SetTEView(aTEView);
- TWindow(aView).Open;
- New(aHandler);
- FailNIL(aHandler);
- aHandler.IStdPrintHandler(SELF, aTEView, NOT kSquareDots, kFixedSize, NOT kFixedSize);
- aHandler.InstallMargins(gZeroRect, kUseMinimalMargins);
- END; {TMPWTextDocument.DoMakeViews}
-
- {$S AClose}
- PROCEDURE TMPWTextDocument.FreeData; OVERRIDE;
-
- BEGIN
- SetHandleSize(fDocText, 0);
- END; {TMPWTextDocument.FreeData}
-
- {$S AClose}
- PROCEDURE TMPWTextDocument.Free; OVERRIDE;
-
- BEGIN
- IF fDocText <> NIL THEN
- DisPosHandle(fDocText);
- INHERITED Free;
- END; {TMPWTextDocument.Free}
-
- {$S AWriteFile}
- PROCEDURE TMPWTextDocument.DoNeedDiskSpace(VAR dataForkBytes, rsrcForkBytes: LongInt);
- OVERRIDE;
-
- BEGIN
- dataForkBytes:= dataForkBytes + GetHandleSize(fDocText);
- rsrcForkBytes:= rsrcForkBytes + kPrintInfoSize + kRsrcTypeOverhead + kRsrcOverhead;
- INHERITED DoNeedDiskSpace(dataForkBytes, rsrcForkBytes);
- END; {TMPWTextDocument.DoNeedDiskSpace}
-
- {$S AWriteFile}
- PROCEDURE TMPWTextDocument.DoWrite(aRefNum: INTEGER; makingCopy: BOOLEAN); OVERRIDE;
-
- VAR
- numChars: LONGINT;
- tempHandle: Handle;
-
- BEGIN
- numChars := GetHandleSize(fDocText);
- FailOSErr(FSWrite(aRefNum, numChars, fDocText^));
- IF fPrintInfo <> NIL THEN { Make sure we have one of these guys}
- BEGIN
- tempHandle := fPrintInfo;
- FailOSErr(HandToHand(tempHandle));
- AddResource(tempHandle, kPrintInfoRsrcType, kPrintInfoRsrcID, '');
- FailResError;
- END;
- END; {TMPWTextDocument.DoWrite}
-
- {$S AFields}
- PROCEDURE TMPWTextDocument.Fields(PROCEDURE DoToField(fieldName: Str255; fieldAddr: Ptr;
- fieldType: INTEGER)); OVERRIDE;
-
- BEGIN
- DoToField('TMPWTextDocument', NIL, bClass);
- DoToField('fDocText', @fDocText, bHandle);
- DoToField('fTEView', @fTEView, bObject);
- DoToField('fDesignDocument', @fDesignDocument, bObject);
- INHERITED Fields(DoToField);
- END; {TMPWTextDocument.Fields}
-
-
- (*************************************)
- (* methods for TMPWInterfaceDocument *)
- (*************************************)
- {$S AOpen}
- PROCEDURE TMPWInterfaceDocument.IMPWInterfaceDocument(theDesignDoc: TDesignDocument;
- theTextHandler: TTextHandler; theName: str255);
-
- BEGIN
- SELF.IMPWTextDocument(theDesignDoc,theTextHandler.GetInterfaceFileName(theName));
- END; {TMPWInterfaceDocument.IMPWInterfaceDocument}
-
- {$S AClose}
- PROCEDURE TMPWInterfaceDocument.Close; OVERRIDE;
-
- BEGIN
- IF fDesignDocument <> NIL THEN
- fDesignDocument.SetMPWCodeView(NIL);
- INHERITED Close;
- END; {TMPWInterfaceDocument.Close}
-
-
- (******************************************)
- (* methods for TMPWImplementationDocument *)
- (******************************************)
-
- {$S AOpen}
- PROCEDURE TMPWImplementationDocument.IMPWImplementationDocument
- (theDesignDoc: TDesignDocument; theTextHandler: TTextHandler; theName: str255);
-
- BEGIN
- SELF.IMPWTextDocument(theDesignDoc,theTextHandler.GetImplementationFileName(theName));
- END; {TMPWImplementationDocument.IMPWImplementationDocument}
-
- {$S AClose}
- PROCEDURE TMPWImplementationDocument.Close; OVERRIDE;
-
- VAR
- theTTEView: TMyTEView;
- theDesignDoc: TDesignDocument;
-
- BEGIN
- theTTEView:= fTEView;
- theDesignDoc:= theTTEView.GetDesignDoc;
- INHERITED Close;
- IF theDesignDoc <> NIL THEN
- theDesignDoc.SetMPWIncCodeView(NIL);
- END; {TMPWInterfaceDocument.Close}
-